Skip to content

feat: add withAlternative alias mechanism for CometConf#4979

Merged
andygrove merged 3 commits into
apache:mainfrom
andygrove:config-alias-machinery
Jul 20, 2026
Merged

feat: add withAlternative alias mechanism for CometConf#4979
andygrove merged 3 commits into
apache:mainfrom
andygrove:config-alias-machinery

Conversation

@andygrove

Copy link
Copy Markdown
Member

Summary

Kicks off the "Review all configuration options and consider renaming some for consistency" item on the 1.0.0 tracker (#4082). This PR lands the machinery + first rename, and files #4978 to track the full rename backlog.

  • Alias mechanism. Adds .withAlternative(oldKey, ...) to ConfigBuilder. Reads check the primary key first, then any registered alternatives in order. Reading a value from an alternative logs a one-time deprecation warning per JVM per alternative key, naming the current key.
  • Threaded through TypedConfigBuilderConfigEntryWithDefault and OptionalConfigEntry, so configs with defaults, env-var overrides, and optional configs all support aliases.
  • Pilot rename. spark.comet.exec.replaceSortMergeJoinspark.comet.exec.forceShuffleHashJoin.enabled (Scala symbol COMET_REPLACE_SMJCOMET_FORCE_SHJ). Old key still works as a deprecated alias.
  • Contributor-guide doc. New "Configuration Conventions" page under docs/source/contributor-guide/ documenting key/symbol naming rules and the rename workflow.
  • Tests. New CometConfSuite covers primary-wins, alternative fallback, default, multiple alternatives, OptionalConfigEntry, type conversion through the alias, and the pilot rename end-to-end.

Related:

Test plan

  • ./mvnw -pl spark test -Dtest=none -Dsuites="org.apache.comet.CometConfSuite" — 7 tests pass locally
  • ./mvnw -pl spark -am compile -DskipTests — clean
  • npx prettier "**/*.md" --write — clean

…ceSortMergeJoin

Introduces `.withAlternative(oldKey, ...)` on `ConfigBuilder`. Reads check the primary
key first, then any registered alternatives in order; reading a value from an alternative
logs a one-time deprecation warning per JVM naming the current key. Threaded through
`TypedConfigBuilder` into `ConfigEntryWithDefault` and `OptionalConfigEntry` so the same
mechanism covers configs with defaults, env-var overrides, and optional configs.

Pilots the mechanism by renaming `spark.comet.exec.replaceSortMergeJoin` to
`spark.comet.exec.forceShuffleHashJoin.enabled` (Scala symbol `COMET_FORCE_SHJ`), keeping
the old key working as an alias.

Adds `CometConfSuite` with tests for primary-wins, alternative fallback, default,
multiple alternatives, OptionalConfigEntry, and type conversion through the alias path.

Adds a Configuration Conventions contributor-guide page that documents the key/symbol
naming rules and the rename workflow.

Broader rename backlog tracked in apache#4978, per the 1.0.0 tracker apache#4082.
…ffix

Rename correction: use the past-participle form matching Spark's `ShuffledHashJoin`
class. Also drops the `.enabled` suffix — the `force` verb already encodes the
boolean action, so `.enabled` is redundant for this key.

Softens the Configuration Conventions doc's boolean-suffix rule accordingly:
descriptor-form flags (debug.enabled, metrics.enabled) still end in `.enabled`;
action-verb flags (force..., allow...) can omit it.
Comment on lines +375 to +377
val COMET_FORCE_SHJ: ConfigEntry[Boolean] =
conf(s"$COMET_EXEC_CONFIG_PREFIX.forceShuffledHashJoin")
.withAlternative(s"$COMET_EXEC_CONFIG_PREFIX.replaceSortMergeJoin")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of renaming a config and preserving the old deprecated name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that replaceSortMergeJoin is deprecated somewhere?

@kazuyukitanimura kazuyukitanimura left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending ci

Comment on lines +375 to +377
val COMET_FORCE_SHJ: ConfigEntry[Boolean] =
conf(s"$COMET_EXEC_CONFIG_PREFIX.forceShuffledHashJoin")
.withAlternative(s"$COMET_EXEC_CONFIG_PREFIX.replaceSortMergeJoin")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that replaceSortMergeJoin is deprecated somewhere?

@andygrove

Copy link
Copy Markdown
Member Author

@kazuyukitanimura since CI is already running, I'll follow up with a docs PR for the one renamed config

@andygrove
andygrove merged commit 957886d into apache:main Jul 20, 2026
70 checks passed
@andygrove
andygrove deleted the config-alias-machinery branch July 20, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants